<?php 
/**
 * @author		: Mauricio de Amorim
 * @date		: 24/11/2010
 * @version		: 1.0
 * @description	: Recebe atraves do $HttpMenuResult array de select para cada tipo de item no menu.
 * Tambem recebe variaveis para cada tipo contendo os ids passados pela requisição
 **/

	  include_once DataHandler::removeDobleBars(Config::FOLDER_REQUEST_CONTROLER."/RootMenu.class.php");
	  //é necessario passar o array de variavel q vem como reposta dentro da reposta da controller pricipal
	  
	  include_once "library/facil3/navigation/vo/BreadCrumbInfoVO.class.php";
	  

	 //TODO: BreadCrumbInfoVO
	  
	  $HttpMenuResult = new RootMenu(	isset( $HttpContentResult->query_menu_filter  )  ? $HttpContentResult->query_menu_filter : FALSE );
	  $HttpMenuResult = $HttpMenuResult->init();
	  $HttpMenuResult = $HttpMenuResult->getHttpContentResult();
	  //Debug::print_r($HttpMenuResult->arrayBreadCrumb);//exit();
	  $HttpMenuResult->url_final = "admin/product/quadro";
?>
	<ul id="menu_vertical">
		<?php if($HttpMenuResult->requestResumeSearch){?>
			<li><h1 ><a href="#">Pesquisa</a></h1>
				<div class="itemSelected"><span ><?php echo $HttpMenuResult->requestResumeSearch;?></span><a class="close" href="<?php echo str_replace("/search.".$HttpMenuResult->requestSearch, "", $HttpMenuResult->url_final)?>">&nbsp;</a></div>
			</li>
		<?php }//end if($HttpMenuResult->requestResumeSearch){
		?>
		
		<?php 
		class ItemMenuLateralVO{
			public $title;
			public $type;
			public $array_item;
			public $selected_id;
			public function __construct($title, $type, $array_item, $selected_id = NULL){
				$this->title 		= $title;
				$this->type 		= $type;
				$this->array_item 	= $array_item;
				$this->selected_id 	= $selected_id;
			}
		}
		//cria a array para loop em todos os tipos do menu
		$array_tipos_menu = array();
		$array_tipos_menu[] = new ItemMenuLateralVO("Edição Limitada", "type", $HttpMenuResult->arrayType, $HttpMenuResult->requestType);
		$array_tipos_menu[] = new ItemMenuLateralVO("Temas", "theme", $HttpMenuResult->arrayTheme, $HttpMenuResult->requestTheme);
		$array_tipos_menu[] = new ItemMenuLateralVO("Técnica", "technique", $HttpMenuResult->arrayTechnique, $HttpMenuResult->requestTechnique);
		$array_tipos_menu[] = new ItemMenuLateralVO("Formato", "format", $HttpMenuResult->arrayFormat, $HttpMenuResult->requestFormat);
		$array_tipos_menu[] = new ItemMenuLateralVO("Estilo", "style", $HttpMenuResult->arrayStyle, $HttpMenuResult->requestStyle);
		$array_tipos_menu[] = new ItemMenuLateralVO("Composição", "composition", $HttpMenuResult->arrayComposition, $HttpMenuResult->requestComposition);
		$array_tipos_menu[] = new ItemMenuLateralVO("Tipo de Produto", "material", $HttpMenuResult->arrayMaterial, $HttpMenuResult->requestMaterial);
		
		
		//agora vai varrer a array de tipos de filtros possíveis e coloca-los no formato
		for($i = 0; $i < count($array_tipos_menu); $i++){
			$ItemMenuLateralVO = $array_tipos_menu[$i];
			if(FALSE){
				$ItemMenuLateralVO = new ItemMenuLateralVO();
			}
			?>
						<li><h1><a href="#"><?php echo $ItemMenuLateralVO->title;?></a></h1>
							<ul>
							<?php 
								$selected 		= "";
								$selected_str 	= "";
								$temp_item = "/$ItemMenuLateralVO->type.".$ItemMenuLateralVO->selected_id."/".DataHandler::strToURL($selected);
								foreach($ItemMenuLateralVO->array_item as $item){
									if((int) $item->total == 0){
										//echo "[".var_dump($ItemMenuLateralVO->selected_id)."]";
										continue;
									}
									if($item->id == $ItemMenuLateralVO->selected_id){
										$selected 		= $item->name;
										$selected_str 	= "/".$ItemMenuLateralVO->type.".".$item->id."/".DataHandler::strToURL($selected);
									}
								$temp_item = "/".$ItemMenuLateralVO->type.".".$item->id."/".DataHandler::strToURL($item->name);
								if($item->id != $ItemMenuLateralVO->selected_id){
								?>
								<li ><a href="<?php echo str_replace($temp_item, "", $HttpMenuResult->url_final).$temp_item;?>"><?php 
								echo $item->name;
								if((int) $item->total > 0){
									echo " (". $item->total .")";
								}
								?></a></li>
							<?php 
								}
								  }//end foreach($HttpMenuResult->arrayMaterial as $item){
								  
								  ?>
							</ul>
							<div class="itemSelected"><span ><?php echo DataHandler::cropString($selected, 15);?></span><a class="close" href="<?php echo str_replace($temp_item, "", $HttpMenuResult->url_final)?>">&nbsp;</a></div>
						</li>
			<?php 
		}// end for($i = 0; $i < count($array_tipos_menu); $i++){
		?>
		<li><h1 ><a>Cor</a></h1>
			<ul class="expanded cor">
			<?php 
				$selected = "";
				$selected_str 	= "";
				//Debug::print_r($HttpMenuResult->arrayColor);
				  foreach($HttpMenuResult->arrayColor as $item){
				  	if($item->id == $HttpMenuResult->requestColor){
				  		$selected = $item->name;
				  		$selected_str 	= "/color.".$item->id."/".DataHandler::strToURL($selected);
				  	}			
					$temp_item = "/color.".$item->id."/".DataHandler::strToURL($item->name);
					if($item->id != $HttpMenuResult->requestColor){
					?>
				<li><a href="<?php echo str_replace($selected_str, "", $HttpMenuResult->url_final).$temp_item?>"><img class="cor" src="<?php echo  Config::getRootPath("image/get_image/image_id.".$item->image[0]->id);   ?>" alt="" title="" /><?php echo $item->name; ?></a></li>
				<?php 
					}
				}
//				echo $item->requestColor;
//				exit();
				$temp_item = "/color.".$HttpMenuResult->requestColor."/".DataHandler::strToURL($selected);
				?>
			</ul>
			<div class="itemSelected"><span><?php echo DataHandler::cropString($selected, 15);?></span><a class="close" href="<?php echo str_replace($temp_item, "", $HttpMenuResult->url_final)?>">&nbsp;</a></div>
		</li>
     </ul>
	